//
//  LaunchiLoL.m
//  ImageReplacer
//
//  Created by Tyler Powell on 5/1/12.
//  Copyright 2012 Georgia Institute of Technology. All rights reserved.
//

#import "LaunchiLoL.h"


@implementation LaunchiLoL
@synthesize sendLaunch;
@synthesize randomizeCheckBox;
@synthesize writer;
- (IBAction)launchiLoL:(id)pId;
{
	NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
	NSFileManager* manager = [NSFileManager defaultManager];
	//NSString* lolPath = getItemFromFileAtIndex(@"options.txt", 0);
    NSString* lolPath = [[writer options]objectAtIndex:0];
	if(![manager fileExistsAtPath:lolPath]){
		//NSLog(@"File does not exist");
        [sendLaunch openiLoLFile:self];
		return;
	}
//	replacePatcherImage(@"images.txt",[randomizeCheckBox state] == NSOnState);
//    replaceFile(@"options.txt", @"PlayButton.png", 3);
//    replaceFile(@"options.txt", @"PlayButtonDisabled.png", 4);
//    replaceFile(@"options.txt", @"patchingComplete.mp3", 5);
//    replaceFile(@"options.txt", @"PvP.net.app/Contents/Resources/assets/swfs/login.swf", 6);
    [writer replaceFiles:[randomizeCheckBox state]];
    [workspace launchApplication:lolPath];
	//[workspace openFile:lolPath];
	sleep(1);
	exit(0);
}
@end
